﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />

    <script src="Scripts/jquery-1.10.2.min.js"></script>
    <script src="Scripts/jquery.signalR-2.2.0.min.js"></script>
    <script src="/signalr/Hubs"></script>
</head>
<body>
    <h1>
        FahimINC Connection protocol test tool
    </h1>
    <h4>
        input a message in textbox and hit send,
        the protocol used to transmit data will be pushed to your device by server and colored in "RED"
    </h4>
    <input type="text" id="message" />
    <input type="button" id="sendButton" value="Send" />
    <ul id="messages"></ul>
    <script>

        function update(message) {
            $('#messages').append('<li>' + message.Sender + ': ' + message.Body + '</li>');
        }

        $(function () {
            var connection = $.hubConnection();
            var hubProxy = connection.createHubProxy('ChatHub');
            hubProxy.on('Update', update);

            connection.start(function () {
                hubProxy.invoke('Identified', { "DeviceId": "122134-CHROME" });
                $('#sendButton').click(function (e) {
                    var name = '';
                    if(window.navigator.appName == "")
                    {
                        name = window.navigator.userAgent;
                    }
                    else
                    {
                        name = window.navigator.appCodeName;
                    }
                    hubProxy.invoke('broadCast', { sender: name, body: $('#message').val() });
                    $('#message').focus();
                });
            });
            
        });
    </script>
</body>
</html>
